//
//  UIButton+Extension.swift
//  weiBo
//
//  Created by 杨雷 on 2016/12/7.
//  Copyright © 2016年 Yang.L. All rights reserved.
//

import UIKit


extension UIButton {
    
    convenience init(imageName: String? = nil, backgroundImageName:String? = nil, title:String? = nil,titleColor: UIColor? = nil, fontSize: CGFloat? = nil) {
        self.init()
        
        if let imgName = imageName {
            self.setImage(UIImage(named: imgName), for:.normal)
        }
        if let bgImgName = backgroundImageName {
            self.setBackgroundImage(UIImage(named: bgImgName), for: .normal)
        }
        if let myTitle = title {
            self.setTitle(myTitle, for: .normal)
        }
        if let myTitleColor = titleColor {
            self.setTitleColor(myTitleColor, for: .normal)
        }
        if let myFontSize = fontSize {
            self.titleLabel?.font = UIFont.systemFont(ofSize: myFontSize)
        }
        
        
    }
    
    
    
}
